package com.xianda.spring.controller;

import com.xianda.spring.entity.TUser;
import com.xianda.spring.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@EnableAutoConfiguration
public class UserController {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private UserService userService;

	@RequestMapping("/findTUser/{id}")
	@ResponseBody
	public TUser findTUser(@PathVariable String id) {
		logger.info("日志输出 trace id={}",id);
		return userService.findTUserById(id);
	}

	@RequestMapping("/saveTUser")
	@ResponseBody
	public int saveTUser(@RequestParam String name) {
		TUser tu = new TUser();
		tu.setName(name);
		return userService.insertUser(tu);
	}
}